class ClientesController < ApplicationController
  before_filter :check_authentication, :except => [:signin]
  
  def check_authentication
    unless session[:user]
      session[:intended_action] = action_name
      session[:intended_controller] = controller_name
      redirect_to :controller => "usuarios", :action => "signin"
    end
  end
  
  active_scaffold :clientes do |config|
    config.label = "Gestión de Clientes"
    config.columns = [:nombre, :ip, :activo, :acelerador, :gateway, :anchob, :correo, :celular, :direccion]
    config.list.columns.exclude :correo, :direccion, :celular
    
    config.create.columns.exclude(:correo, :direccion, :celular)
    
    config.create.columns.add_subgroup "Opcional" do |group|
      group.add(:correo, :direccion, :celular)
    end
    
  end
  
  def detener
    Cliente.stop
    redirect_to :action => "index"
  end
  
  def reiniciar
    Cliente.restart
    redirect_to :action => "index"
  end
end
